<?php

	namespace app\common\model\goods;

	use addons\vip\library\OrderException;
	use app\common\library\Auth;
	use app\common\model\User;
	use think\Db;
	use think\Exception;
	use think\Model;

	class Orders extends Model{

		// 表名
		protected $name = 'orders';
		// 自动写入时间戳字段
		protected $autoWriteTimestamp = 'int';
		// 定义时间戳字段名
		protected $createTime = 'createtime';
		protected $updateTime = 'updatetime';

		protected $append = ['paytype_text','status_text'];

		public function getPaytypeTextAttr($value, $data){
			$types = [
				'wechat' => '微信支付',
				'alipay' => '支付宝支付',
				'balance' => '余额支付',
			];
			return isset($types[$data['paytype']]) ? $types[$data['paytype']] : '未知';
		}

		public function getStatusTextAttr($value, $data){
			$status = [
				'created' => '未支付',
				'paid'    => '已支付',
				'expired' => '已过期',
			];
			return isset($status[$data['status']]) ? $status[$data['status']] : '未知';
		}

	}